package cn.iocoder.yudao.module.infrastructure.dept.controller.app;

import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.infrastructure.dept.controller.admin.vo.dept.DeptListReqVO;
import cn.iocoder.yudao.module.infrastructure.dept.controller.admin.vo.dept.DeptSimpleRespVO;
import cn.iocoder.yudao.module.infrastructure.dept.dal.dataobject.DeptDO;
import cn.iocoder.yudao.module.infrastructure.dept.service.DeptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 App - 部门") // FIXME 新增
@RestController("patchAppDeptController")
@RequestMapping("/system/dept")
@Validated
public class AppDeptController {

    @Resource
    private DeptService deptService;

    @GetMapping(value = "simple-list")
    @Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门，主要用于前端的下拉选项")
    public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
        DeptListReqVO deptListReqVO = new DeptListReqVO();
        deptListReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
        List<DeptDO> list = deptService.getDeptList(deptListReqVO);
        return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
    }

}
